"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const index = require("./sub/index.js");
const utils = require("utils");
const dbHandle = require("./sub/dbHandle.js");
async function aliLoginAction(param) {
  let { code } = param || {};
  if (utils.util.emptyValue(code)) {
    return utils.util.resErr(new utils.ParamErr("code"));
  }
  let [parseErr, parseData] = await index._codeParse(code);
  if (!utils.util.nilValue(parseErr)) {
    return utils.util.resErr(parseErr);
  }
  let tokenData = parseData;
  let [userErr, userData] = await index._getUserInfo(tokenData.access_token);
  if (!utils.util.nilValue(userErr)) {
    return utils.util.resErr(userErr);
  }
  let userInfo = userData;
  let [dbErr, dbData] = await dbHandle.dbHandle(tokenData, userInfo);
  if (!utils.util.nilValue(dbErr)) {
    return utils.util.resErr(dbErr);
  }
  return utils.util.resData(dbData);
}
exports.aliLoginAction = aliLoginAction;
